Java is an object oriented programming language and environment focusing on defining data as objects and the methods that may be applied to those objects. Java supports only a single inheritance, meaning that each class can inherit from only one other class at any given time. Java also allows for the creation of totally abstract classes known as interfaces, which allow the defining of methods that may be shared with several classes without regard for how other classes are handling the methods. Java provides a mechanism to distribute software and extends the capabilities of a Web browser because programmers can write an applet once and the applet can be run on any Java enabled machine on the Web.
Java objects may invoke other Java objects. Enterprise Java Beans (EJB) is a component software architecture that is used to build Java applications (objects) that run in a server. EJB uses a “container” layer that provides common functions such as security and transaction support and delivers a consistent interface to the applications regardless of the type of server.
Currently, the EJB 1.0 and 1.1 specification requires the implementation of a call by value as opposed to a call by reference for the invocation of EJBs. This same requirement may apply to future versions of the EJB or other programming specifications. When the EJB lives in the same container as the caller, it is more efficient to pass a reference to objects used by the EJB rather than making a copy of the object. However, passing a reference exposes the caller to corruption of the passed object.
There are instances, however, when a passed object does not need to be copied because it is immutable, meaning that once the object is created it cannot be modified. In these instances, the object may be referenced because there is no danger of corruption and the semantic of pass by value is maintained.
In the prior art, the solution used by Application Server vendors is to provide an override at runtime allowing the customer to choose to pass by reference rather than by value. Although this provides better performance, it also exposes the customer to a violation of the EJB specification and the object may be corrupted if it is not immutable.
Therefore, it would be advantageous to provide a method, apparatus, and program to determine the mutability of an object at loading time to avoid unnecessarily copying an object when passing the object as an argument when invoking a program object.